﻿@{
    ViewBag.Title = "完善注册信息";
}
@model ZBJF.Warranty.Model.ViewModel.Sellers.SellerEmployeeModel
<div class="desc_forward_title" onclick="history.back(-1)">
    填写注册信息
</div>
@using (Html.BeginForm("NextToConfirmRegistInfo", "Register", FormMethod.Post, new { id = "resiterForm" }))
{
    <div class="register weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                @Html.HiddenFor(m => m.UserPhone)
                @Html.TextBoxFor(m => m.UserName, new { @class = "weui-input user-name", placeholder = "请输入姓名", validate = "{required:true,messages:{required:'请输入姓名'}}" })
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__bd">
                @Html.TextBoxFor(m => m.CertificateNO, new { @class = "weui-input user-certificate", placeholder = "请输入身份证号", validate = "{required:true,isIdCardNo:true,messages:{required:'请输入身份证号'}}" })
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__bd">
                @Html.PasswordFor(m => m.Password, new { @class = "weui-input vcode", placeholder = "请输入登录密码", validate = "{required:true,minlength:6,messages:{required:'请输入登录密码',minlength:'密码长度不能小于6位！'}}" })
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__bd">
                @Html.PasswordFor(m => m.ConfirmNewPassword, new { @class = "weui-input vcode", placeholder = "请再次确认密码", validate = "{required:true,equalTo:Password,messages:{required:'请再次确认密码',equalTo:'两次输入的密码不一致！'}}" })
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__bd">
                @Html.TextBoxFor(m => m.SellerCode, new { @class = "weui-input seller-code", placeholder = "请输入销售机构代码", validate = "{required:true,messages:{required:'请输入销售机构代码'}}" })
            </div>
        </div>
    </div>
    <div class="margin-t-30 w-p90">
        <a href="javascript:void(0)" class="weui-form-preview__btn weui-form-preview__btn_primary border-radius-6" onclick="if ($('#resiterForm').valid()) {$('#resiterForm').submit(); } else { return false };">
            下一步
        </a>
    </div>
}
<script type="text/javascript">
    $(function() {
        $("#resiterForm").submit(function() {
            return isSellerCodeExist();
        });
        $("#SellerCode").blur(function() {
            isSellerCodeExist();
        });
    });

    function isSellerCodeExist() {
        var validateResult = false;
        $.ajax({
            url: "/Register/IsSellerCodeExist",
            cache: false,
            type: "post",
            async: false,
            data: {
                SellerCode: function () { return $("#SellerCode").val(); }
            },
            success: function (data) {
                if (data == "False") {
                    layer.msg("销售代码不正确！", { icon: 2 });
                    validateResult = false;
                } else {
                    validateResult = true;
                }
            }
        });
        return validateResult;
    }
</script>